package cn.hist.hfp.util;

import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

@Component
public class MyResponse<T> {

    public ResponseEntity<T> response(int status, String token, T t) {
        return ResponseEntity
                .status(status)
                .header("Access-Control-Allow-Origin", "*")
                .header("Access-Control-Allow-Methods", "POST, GET")
                .header("Custom-Header", "Own-Data")
                .header("Access-Control-Expose-Headers", "Custom-Header")
                .header("token", token)
                .body(t);
    }

    public ResponseEntity<T> response(int status, T t) {
        return ResponseEntity
                .status(status)
                .body(t);
    }
}
